package com.zy.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zy.entity.Customer;
import com.zy.service.CustomerService;
import com.zy.service.impl.CustomerServiceImpl;

/**
 * Servlet implementation class QueryByName
 */
@WebServlet("/QueryByName")
public class QueryByName extends HttpServlet {
	CustomerService cs = new CustomerServiceImpl();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String name = request.getParameter("custname");
		
		List<Customer> customers = cs.queryByName(name);
		request.setAttribute("list", customers);
		request.getRequestDispatcher("/WEB-INF/customer/list.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
